/**
 */
package mvc_generator.mVCGenerator.impl;

import java.util.Collection;

import mvc_generator.mVCGenerator.Bloc;
import mvc_generator.mVCGenerator.Condition;
import mvc_generator.mVCGenerator.MVCGeneratorPackage;
import mvc_generator.mVCGenerator.View;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Bloc</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link mvc_generator.mVCGenerator.impl.BlocImpl#getBlocDescription <em>Bloc Description</em>}</li>
 *   <li>{@link mvc_generator.mVCGenerator.impl.BlocImpl#getConditions <em>Conditions</em>}</li>
 *   <li>{@link mvc_generator.mVCGenerator.impl.BlocImpl#getViewOnSuccess <em>View On Success</em>}</li>
 *   <li>{@link mvc_generator.mVCGenerator.impl.BlocImpl#getErrorDescription <em>Error Description</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class BlocImpl extends MinimalEObjectImpl.Container implements Bloc
{
  /**
   * The default value of the '{@link #getBlocDescription() <em>Bloc Description</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getBlocDescription()
   * @generated
   * @ordered
   */
  protected static final String BLOC_DESCRIPTION_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getBlocDescription() <em>Bloc Description</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getBlocDescription()
   * @generated
   * @ordered
   */
  protected String blocDescription = BLOC_DESCRIPTION_EDEFAULT;

  /**
   * The cached value of the '{@link #getConditions() <em>Conditions</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getConditions()
   * @generated
   * @ordered
   */
  protected EList<Condition> conditions;

  /**
   * The cached value of the '{@link #getViewOnSuccess() <em>View On Success</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getViewOnSuccess()
   * @generated
   * @ordered
   */
  protected View viewOnSuccess;

  /**
   * The default value of the '{@link #getErrorDescription() <em>Error Description</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getErrorDescription()
   * @generated
   * @ordered
   */
  protected static final String ERROR_DESCRIPTION_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getErrorDescription() <em>Error Description</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getErrorDescription()
   * @generated
   * @ordered
   */
  protected String errorDescription = ERROR_DESCRIPTION_EDEFAULT;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected BlocImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return MVCGeneratorPackage.Literals.BLOC;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getBlocDescription()
  {
    return blocDescription;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setBlocDescription(String newBlocDescription)
  {
    String oldBlocDescription = blocDescription;
    blocDescription = newBlocDescription;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MVCGeneratorPackage.BLOC__BLOC_DESCRIPTION, oldBlocDescription, blocDescription));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Condition> getConditions()
  {
    if (conditions == null)
    {
      conditions = new EObjectContainmentEList<Condition>(Condition.class, this, MVCGeneratorPackage.BLOC__CONDITIONS);
    }
    return conditions;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public View getViewOnSuccess()
  {
    if (viewOnSuccess != null && viewOnSuccess.eIsProxy())
    {
      InternalEObject oldViewOnSuccess = (InternalEObject)viewOnSuccess;
      viewOnSuccess = (View)eResolveProxy(oldViewOnSuccess);
      if (viewOnSuccess != oldViewOnSuccess)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, MVCGeneratorPackage.BLOC__VIEW_ON_SUCCESS, oldViewOnSuccess, viewOnSuccess));
      }
    }
    return viewOnSuccess;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public View basicGetViewOnSuccess()
  {
    return viewOnSuccess;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setViewOnSuccess(View newViewOnSuccess)
  {
    View oldViewOnSuccess = viewOnSuccess;
    viewOnSuccess = newViewOnSuccess;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MVCGeneratorPackage.BLOC__VIEW_ON_SUCCESS, oldViewOnSuccess, viewOnSuccess));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getErrorDescription()
  {
    return errorDescription;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setErrorDescription(String newErrorDescription)
  {
    String oldErrorDescription = errorDescription;
    errorDescription = newErrorDescription;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MVCGeneratorPackage.BLOC__ERROR_DESCRIPTION, oldErrorDescription, errorDescription));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.BLOC__CONDITIONS:
        return ((InternalEList<?>)getConditions()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.BLOC__BLOC_DESCRIPTION:
        return getBlocDescription();
      case MVCGeneratorPackage.BLOC__CONDITIONS:
        return getConditions();
      case MVCGeneratorPackage.BLOC__VIEW_ON_SUCCESS:
        if (resolve) return getViewOnSuccess();
        return basicGetViewOnSuccess();
      case MVCGeneratorPackage.BLOC__ERROR_DESCRIPTION:
        return getErrorDescription();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.BLOC__BLOC_DESCRIPTION:
        setBlocDescription((String)newValue);
        return;
      case MVCGeneratorPackage.BLOC__CONDITIONS:
        getConditions().clear();
        getConditions().addAll((Collection<? extends Condition>)newValue);
        return;
      case MVCGeneratorPackage.BLOC__VIEW_ON_SUCCESS:
        setViewOnSuccess((View)newValue);
        return;
      case MVCGeneratorPackage.BLOC__ERROR_DESCRIPTION:
        setErrorDescription((String)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.BLOC__BLOC_DESCRIPTION:
        setBlocDescription(BLOC_DESCRIPTION_EDEFAULT);
        return;
      case MVCGeneratorPackage.BLOC__CONDITIONS:
        getConditions().clear();
        return;
      case MVCGeneratorPackage.BLOC__VIEW_ON_SUCCESS:
        setViewOnSuccess((View)null);
        return;
      case MVCGeneratorPackage.BLOC__ERROR_DESCRIPTION:
        setErrorDescription(ERROR_DESCRIPTION_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.BLOC__BLOC_DESCRIPTION:
        return BLOC_DESCRIPTION_EDEFAULT == null ? blocDescription != null : !BLOC_DESCRIPTION_EDEFAULT.equals(blocDescription);
      case MVCGeneratorPackage.BLOC__CONDITIONS:
        return conditions != null && !conditions.isEmpty();
      case MVCGeneratorPackage.BLOC__VIEW_ON_SUCCESS:
        return viewOnSuccess != null;
      case MVCGeneratorPackage.BLOC__ERROR_DESCRIPTION:
        return ERROR_DESCRIPTION_EDEFAULT == null ? errorDescription != null : !ERROR_DESCRIPTION_EDEFAULT.equals(errorDescription);
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (blocDescription: ");
    result.append(blocDescription);
    result.append(", errorDescription: ");
    result.append(errorDescription);
    result.append(')');
    return result.toString();
  }

} //BlocImpl
